package com.banach.prema.im.util;

import java.util.Random;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class CommonUtils {
	
	/**
	 * 产生一个随机len位的数：
	 * @param len 随机数长度
	 * @return
	 */
	public static String getRdm(int len){
		StringBuilder str=new StringBuilder();//定义变长字符串
		Random random=new Random();
		//随机生成数字，并添加到字符串
		for(int i=0;i<len;i++){
		    str.append(random.nextInt(10));
		}
		return str.toString();
	}
	
	public static boolean isphone(String phone) {
		if(phone==null){
			return false;
		}
		String regex = "^(1[0-9][0-9])\\d{8}$"; 
		Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
		Matcher m = pattern.matcher(phone);
		String province = "";
		return m.find();
	}
}
